home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
clipper
/
nfsrc21.zip
/
MOUSE1.PRG
< prev
next >
Wrap
Text File
|
1992-10-17
|
46KB
|
1,557 lines
/*
* File......: MOUSE1.PRG
* Author....: Leo Letendre
* CIS ID....: 73607,233
* Date......: $Date: 17 Oct 1992 16:28:58 $
* Revision..: $Revision: 1.9 $
* Log file..: $Logfile: C:/nanfor/src/mouse1.prv $
*
* This is an original work by Robert DiFalco and is placed in the
* public domain.
*
* Modification history:
* ---------------------
*
* $Log: C:/nanfor/src/mouse1.prv $
*
* Rev 1.9 17 Oct 1992 16:28:58 GLENN
* Leo cleaned up documentation blocks.
*
* Rev 1.8 28 Sep 1992 01:38:14 GLENN
* Leo added FT_MGETSENS(), FT_MSETSENS(), FT_MSETPAGE(), FT_MGETPAGE(),
* and FT_MVERSION().
*
*
* Rev 1.7 01 Jul 1992 01:45:18 GLENN
* Leo added documentation to FT_MDEFCRS and others. Added FT_MCONOFF(),
* FT_MINIT(), FT_MGETCOORD() and FT_MSETCOORD(). Restructured
* FT_MGETX() and FT_MGETY() for possible speed improvement and MAIN to
* better demonstrate some of the concerns when programming the mouse.
* Added ability to change the number of rows and columns to demonstrate
* use in 43, 50 row mode etc. which is now supported in FT_MRESET() and
* FT_MINIT().
*
* Rev 1.6 23 Sep 1991 01:14:38 GLENN
* Corrected errors in syntax documention for FT_MBUTPRS() and FT_MDBLCLK(),
* found by Nantucket's Steve Silverwood.
*
* Rev 1.5 17 Aug 1991 15:34:52 GLENN
* Don Caton fixed some spelling errors in the doc
*
* Rev 1.4 15 Aug 1991 23:06:24 GLENN
* Forest Belt proofread/edited/cleaned up doc
*
* Rev 1.3 17 Jul 1991 22:28:40 GLENN
* Leo fixed a potential bug in ft_mcursor().
*
* Rev 1.2 27 May 1991 13:40:30 GLENN
* Leo Letendre sent me a revision of MOUSE1.PRG where he built in support
* for a three-button mouse, and revised the "double click" detection
* algorithm.
*
* Brought in compliance with new ft_int86().
*
* Rev 1.1 11 May 1991 00:16:48 GLENN
* ft_mgetpos() had a bug where the x and y coordinates were reversed.
* Changed x coordinate to aRegs[3] and y coordinate to aRegs[4], just
* like in ft_msetpos().
*
* Rev 1.0 01 Apr 1991 01:01:48 GLENN
* Nanforum Toolkit
*
*/
// The original mouse routines were written by Robert diFalco but
// Leo Letendre has made such major additions and modifications
// and fixes that I've given him sole credit. -- G. Scott
#include "FTINT86.CH"
static aReg[INT86_MAX_REGS]
static lCrsState:=.F.
static lMinit:=.F.
#ifdef FT_TEST
FUNCTION MAIN(nRow,nCol)
* Pass valid row and column values for different video modes to change modes
local nX, nY, cSavClr
local cSavScr := savescreen( 0, 0, maxrow(), maxcol() )
local nXm, nYm
local nSaveRow:=MAXROW()+1, nSaveCol:=MAXCOL()+1
local nMinor, nType, nIRQ
local aType:={"Bus","Serial","InPort","PS/2","HP"}
local nHoriz, nVert, nDouble
local nTime
IF nRow=NIL
nRow=MAXROW()+1
ELSE
nRow=VAL(nRow)
ENDIF
IF nCol=NIL
nCol=MAXCOL()+1
ELSE
nCol=VAL(nCol)
ENDIF
IF .NOT.SETMODE(nRow,nCol)
@maxrow(),0 SAY "Mode Change unsuccessful:"+STR(nRow,2,0)+" by";
+STR(nCol,3,0)
RETURN NIL
ENDIF
if empty( FT_MINIT() )
@ maxrow(), 0 say "Mouse driver is not installed!"
SETMODE(nSaveRow,nSaveCol)
return ""
endif
* ..... Set up the screen
cSavClr := setcolor( "w/n" )
@ 0,0,maxrow(),maxcol() box "░░░░░░░░░"
setcolor( "GR+/RB" )
scroll( 7,2,19,63,0 )
@ 7,2 to 20,63
@ 17, 10 to 19, 40 double
setcolor( "N/W" )
@ 18, 11 say " Double Click here to Quit "
setcolor( "GR+/RB" )
* ..... Start the demo
@MAXROW(),0 SAY "Driver version: "+;
ALLTRIM(STR(FT_MVERSION(@nMinor,@nType,@nIRQ),2,0))+"."+;
ALLTRIM(STR(nMinor,2,0))
@ ROW(),COL() SAY " "+aType[nType]+" mouse using IRQ "+STR(nIRQ,1,0)
FT_MGETSENS(@nHoriz,@nVert,@nDouble) // Get the current sensitivities
FT_MSETSENS(70,70,60) // Bump up the sensitivity of the mouse
FT_MSHOWCRS()
FT_MSETCOORD(10,20) // just an arbitrary place for demo
* put the unchanging stuff
devpos( 9, 10 )
devout( "FT_MMICKEYS :" )
devpos( 10, 10 )
devout( "FT_MGETPOS :" )
devpos( 11, 10 )
devout( "FT_MGETX :" )
devpos( 12, 10 )
devout( "FT_MGETY :")
devpos( 13, 10 )
devout( "FT_MGETCOORD:" )
devpos( 14, 10 )
devout( "FT_MBUTPRS :" )
devpos( 16, 10 )
devout( "FT_MBUTREL :" )
nX := nY := 1
do while .t.
* If we are not moving then wait for movement.
* This whole demo is a bit artificial in its requirements when compared
* to a "normal" CLIPPER program so some of these examples are a bit out of
* the ordinary.
DO WHILE nX=0.AND.nY=0
FT_MMICKEYS( @nX, @nY )
ENDDO
* tell the mouse driver where updates will be taking place so it can hide
* the cursor when necessary.
FT_MCONOFF( 9, 23, 16, 53 )
nTime=-1
devpos( 9, 23 )
devout( nX )
devout( nY )
devpos( 10, 23 )
DEVOUT( FT_MGETPOS( @nX, @nY ) )
devout( nX )
devout( nY )
devpos( 11, 23 )
DEVOUT( FT_MGETX() )
devpos( 12, 23 )
DEVOUT( FT_MGETY() )
devpos( 13, 23 )
devout( FT_MGETCOORD( @nX, @nY ) )
devout ( nX )
devout ( nY )
nX:=nY:=0
devpos( 14, 23 )
DEVOUT( FT_MBUTPRS(1) )
DEVOUT( FT_MBUTPRS(0,, nX, nY) )
devpos( 15, 23 )
* show only the last Press since it flashes by so quickly
IF nX!=0.OR.nY!=0
devout( nX )
devout( nY )
endif
nX:=nY:=0
devpos( 16, 23 )
devout( FT_MBUTREL(0,, @nX, @nY) )
* show only the last release since it flashes by so quickly
if nX!=0.OR.nY!=0
devout( nX )
devout( nY )
endif
* Restore the cursor if it has been hidden
FT_MSHOWCRS()
if FT_MINREGION( 18, 11, 18, 39 )
* Change the type of cursor when in the box. Just slightly different than the
* normal. The character is shown in high intensity.
FT_MDEFCRS(0,32767,32512)
if FT_MDBLCLK(2,0,0.8)
exit
endif
endif
if FT_MINREGION( 18, 11, 18, 39 )
* Change the type of cursor when in the box. Just slightly different than the
* normal. The character is shown in high intensity.
FT_MDEFCRS(0,32767,32512)
else
* Put the cursor back to normal mode
FT_MDEFCRS(0,30719,30464)
endif
FT_MMICKEYS( @nX, @nY )
enddo
FT_MHIDECRS()
SETMODE(nSaveRow,nSaveCol)
setcolor( cSavClr )
restscreen( 0, 0, maxrow(), maxcol(), cSavScr )
devpos( maxrow(), 0 )
// Reset sensitivity
FT_MSETSENS(nHoriz, nVert, nDouble)
RETURN nil
#endif
/*
* $DOC$
* $FUNCNAME$
* FT_MINIT()
* $CATEGORY$
* Keyboard/Mouse
* $ONELINER$
* Initialize the mouse driver, vars and return status of mouse
* $SYNTAX$
* FT_MINIT() -> lMouseStatus
* $ARGUMENTS$
* NONE
* $RETURNS$
* An logical representing the mouse status (.F. == mouse not installed)
* $DESCRIPTION$
* Initializes the mouse drive, associated variables and returns mouse
* status. It checks to see if the mouse has been previously initialized
* and if so it does not reinitialize. The row and column limits of mouse
* movement is set to the maximum for the current video mode.
* Use FT_MSHOWCRS() to display the mouse cursor.
* $EXAMPLES$
* IF .NOT. FT_MINIT()
* ? "No mouse driver is installed"
* ENDIF
* $SEEALSO$
* FT_MRESET()
* $END$
*/
FUNCTION FT_MINIT()
* If not previously initialized then try
IF !lMinit
lMinit=(FT_MRESET()!=0)
ELSE
* Reset maximum x and y limits
FT_MYLIMIT(0,8*MAXROW())
FT_MXLIMIT(0,8*MAX